<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>链拍Pro - 智能合约竞拍平台</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', sans-serif;
        }

        body {
            background: #121212;
            color: #fff;
            line-height: 1.6;
        }

        /* 动态背景 */
        #bg-canvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }

        /* 导航栏 */
        .navbar {
            position: fixed;
            width: 100%;
            background: rgba(26, 35, 126, 0.9);
            padding: 1rem 4rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            z-index: 1000;
        }

        .logo {
            display: flex;
            align-items: center;
        }

        .logo img {
            height: 36px;
            margin-right: 0.5rem;
        }

        .nav-links a {
            color: #fff;
            text-decoration: none;
            margin-left: 2rem;
            position: relative;
        }

        .nav-links a:hover {
            color: #00ff88;
        }

        .wallet-btn {
            background: #00ff88;
            color: #121212;
            padding: 0.5rem 1.5rem;
            border-radius: 25px;
            font-weight: 600;
            transition: transform 0.3s;
        }

        .wallet-btn:hover {
            transform: scale(1.05);
        }

        /* 主内容区 */
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 8rem 2rem;
        }

        /* 竞拍列表 */
        .auction-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 3rem;
            margin-top: 4rem;
        }

        .auction-card {
            background: #263238;
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s;
        }

        .auction-card:hover {
            transform: translateY(-5px);
        }

        .auction-image {
            width: 100%;
            height: 200px;
            object-fit: cover;
        }

        .card-content {
            padding: 1.5rem;
        }

        .price {
            color: #00ff88;
            font-size: 1.8rem;
            font-weight: 700;
            margin: 1rem 0;
        }

        .countdown {
            color: #ff4444;
            font-size: 1.2rem;
            margin-bottom: 1rem;
        }

        .btn {
            display: inline-block;
            background: #007bff;
            color: #fff;
            padding: 0.8rem 2rem;
            border-radius: 25px;
            text-decoration: none;
            font-weight: 600;
            transition: background 0.3s;
        }

        .btn:hover {
            background: #0056b3;
        }

        /* 详情页 */
        .detail-container {
            display: grid;
            grid-template-columns: 2fr 1fr;
            gap: 4rem;
            margin-top: 6rem;
        }

        .nft-preview {
            background: #263238;
            border-radius: 15px;
            padding: 2rem;
            text-align: center;
        }

        .nft-image {
            width: 100%;
            max-width: 400px;
            margin: 0 auto 1.5rem;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        }

        .contract-address {
            color: #00ff88;
            font-size: 0.9rem;
            margin: 1rem 0;
        }

        .bid-panel {
            background: #263238;
            border-radius: 15px;
            padding: 2rem;
        }

        .bid-input {
            width: 100%;
            padding: 1rem;
            background: #1a1a1a;
            color: #fff;
            border: none;
            border-radius: 25px;
            margin: 1rem 0;
        }

        /* 科技风动画 */
        .glow {
            animation: glow 1.5s infinite;
        }

        @keyframes glow {
            0% { box-shadow: 0 0 10px rgba(0, 255, 136, 0.3); }
            50% { box-shadow: 0 0 20px rgba(0, 255, 136, 0.6); }
            100% { box-shadow: 0 0 10px rgba(0, 255, 136, 0.3); }
        }

        /* 倒计时警告样式 */
        .warning {
            animation: warning 1s infinite;
        }

        @keyframes warning {
            0% { color: #ff4444; }
            50% { color: #ffaa00; }
            100% { color: #ff4444; }
        }
    </style>
</head>
<body>
    <canvas id="bg-canvas"></canvas>
    
    <nav class="navbar">
        <div class="logo">
            <img src="" alt="链拍LOGO">
            <h1>链拍Pro</h1>
        </div>
        <div class="nav-links">
            <a href="#auctions">竞拍大厅</a>
            <a href="#create">创建竞拍</a>
            <a href="#profile">我的资产</a>
            <button class="wallet-btn glow" onclick="connectWallet()">连接钱包</button>
        </div>
    </nav>

    <main class="container">
        <h2 class="text-3xl mb-6">热门竞拍 <span class="text-sm text-gray-400">(实时更新)</span></h2>
        
        <div class="auction-grid" id="auctions">
            <!-- 竞拍卡片模板 -->
            <div class="auction-card">
                <img src="https://picsum.photos/300/200?random=1" alt="NFT" class="auction-image">
                <div class="card-content">
                    <h3 class="text-xl mb-2">Cyberpunk City #42</h3>
                    <div class="countdown" data-end-time="2025-05-20T23:59:59">加载中...</div>
                    <div class="price">1.2 ETH</div>
                    <p class="text-sm text-gray-400">出价次数：23次</p>
                    <a href="#detail" class="btn mt-4">查看详情</a>
                </div>
            </div>

            <div class="auction-card">
                <img src="https://picsum.photos/300/200?random=2" alt="NFT" class="auction-image">
                <div class="card-content">
                    <h3 class="text-xl mb-2">Digital Artifact #7</h3>
                    <div class="countdown" data-end-time="2025-05-19T18:30:00">加载中...</div>
                    <div class="price">0.8 ETH</div>
                    <p class="text-sm text-gray-400">出价次数：18次</p>
                    <a href="#detail" class="btn mt-4">查看详情</a>
                </div>
            </div>
        </div>

        <!-- 竞拍详情页模拟 -->
        <div class="detail-container" id="detail">
            <div class="nft-preview">
                <img src="https://picsum.photos/400/400?random=3" alt="NFT详情" class="nft-image">
                <h2 class="text-2xl mb-2">Cyberpunk City #42</h2>
                <p class="contract-address">合约地址：0xAbc123...</p>
                <div class="bg-green-100 text-green-600 px-2 py-1 rounded-full mb-4">拍卖中</div>
                <div class="countdown" data-end-time="2025-05-20T23:59:59" style="font-size: 1.5rem;"></div>
            </div>

            <div class="bid-panel">
                <h2 class="text-xl mb-4">参与竞拍</h2>
                <input type="number" placeholder="输入出价金额（ETH）" class="bid-input" value="1.3">
                <button class="btn w-full mt-4" onclick="placeBid()">立即出价</button>
                <div class="text-sm text-gray-400 mt-3">
                    自动出价：设置最高限价，系统将自动帮您竞价
                </div>
            </div>
        </div>
    </main>

    <script>
        // 动态背景绘制
        const canvas = document.getElementById('bg-canvas');
        const ctx = canvas.getContext('2d');
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;

        function drawBackground() {
            ctx.fillStyle = 'rgba(18, 18, 18, 0.1)';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            ctx.strokeStyle = '#00ff88';
            ctx.lineWidth = 1;
            
            for (let i = 0; i < 150; i++) {
                const x1 = Math.random() * canvas.width;
                const y1 = Math.random() * canvas.height;
                const x2 = x1 + Math.random() * 100 - 50;
                const y2 = y1 + Math.random() * 100 - 50;
                
                ctx.beginPath();
                ctx.moveTo(x1, y1);
                ctx.lineTo(x2, y2);
                ctx.stroke();
            }
            
            requestAnimationFrame(drawBackground);
        }
        drawBackground();

        // 模拟钱包连接
        function connectWallet() {
            alert('正在连接MetaMask钱包...');
            // 实际需添加Web3.js连接逻辑
        }

        // 模拟出价
        function placeBid() {
            alert('出价已提交，等待区块链确认...');
            // 实际需调用智能合约方法
        }

        // 倒计时功能
        function updateCountdowns() {
            const countdownElements = document.querySelectorAll('.countdown');
            
            countdownElements.forEach(element => {
                const endTimeStr = element.getAttribute('data-end-time');
                if (!endTimeStr) return;
                
                const endTime = new Date(endTimeStr).getTime();
                const now = new Date().getTime();
                const timeLeft = endTime - now;
                
                if (timeLeft <= 0) {
                    element.textContent = '拍卖已结束';
                    element.classList.add('warning');
                    return;
                }
                
                // 计算剩余时间
                const days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
                const hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
                const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
                
                // 格式化显示
                let displayTime = '';
                if (days > 0) {
                    displayTime = `${days}天 ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
                } else {
                    displayTime = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
                }
                
                element.textContent = displayTime;
                
                // 倒计时小于10分钟时添加警告样式
                if (timeLeft < 10 * 60 * 1000) {
                    element.classList.add('warning');
                } else {
                    element.classList.remove('warning');
                }
            });
        }

        // 每秒更新一次倒计时
        setInterval(updateCountdowns, 1000);
        // 页面加载时立即更新一次
        updateCountdowns();
    </script>
</body>
</html>